<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" >
  <link rel="dns-prefetch" href="http://yoursite.com">
  <title>sonar学习笔记 | Jakie13个人博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="sonar简介sonar是一款强大的代码质量管理软件。支持本地和服务端分析
sonarQubesonarQube是sonar的服务端。使用sonarQube可以自己假设sonar的服务端，并通过网站访问管理。  
下载官网地址：http://www.sonarqube.org/ps:  

以前的版本是sonarQube和sonarRunner，现在已不支持。qube至少要5.X版本，最好使用最新">
<meta property="og:type" content="article">
<meta property="og:title" content="sonar学习笔记">
<meta property="og:url" content="http://yoursite.com/2016/12/06/sonar学习笔记/index.html">
<meta property="og:site_name" content="Jakie13个人博客">
<meta property="og:description" content="sonar简介sonar是一款强大的代码质量管理软件。支持本地和服务端分析
sonarQubesonarQube是sonar的服务端。使用sonarQube可以自己假设sonar的服务端，并通过网站访问管理。  
下载官网地址：http://www.sonarqube.org/ps:  

以前的版本是sonarQube和sonarRunner，现在已不支持。qube至少要5.X版本，最好使用最新">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube001.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube002.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube003.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube004.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube005.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube006.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube007.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube008.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner001.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner002.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner003.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner004.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner005.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner006.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner007.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner009.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner008.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner015.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner010.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner011.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner012.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner013.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner014.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint001.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint002.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint003.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint004.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint005.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint006.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint007.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint008.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint009.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint010.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint011.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint012.jpg">
<meta property="og:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint013.jpg">
<meta property="og:updated_time" content="2016-12-13T01:40:16.789Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="sonar学习笔记">
<meta name="twitter:description" content="sonar简介sonar是一款强大的代码质量管理软件。支持本地和服务端分析
sonarQubesonarQube是sonar的服务端。使用sonarQube可以自己假设sonar的服务端，并通过网站访问管理。  
下载官网地址：http://www.sonarqube.org/ps:  

以前的版本是sonarQube和sonarRunner，现在已不支持。qube至少要5.X版本，最好使用最新">
<meta name="twitter:image" content="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube001.jpg">
  
    <link rel="alternative" href="/atom.xml" title="Jakie13个人博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  <link rel="stylesheet" href="/main.css?v=4.0.0.css">
  

</head>

<body>
  <div id="container" q-class="show:isCtnShow">
    <canvas id="anm-canvas" class="anm-canvas"></canvas>
    <div class="left-col" q-class="show:isShow">
      <div class="overlay"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			<img src="http://ohsk3zt5q.bkt.clouddn.com/head_image.JPG" class="js-avatar">
		</a>

		<hgroup>
		  <h1 class="header-author"><a href="/">Jakie13</a></h1>
		</hgroup>

		

		<nav class="header-menu">
			<ul>
			
				<li><a href="/">主页</a></li>
	        
				<li><a href="/tags/随笔/">随笔</a></li>
	        
			</ul>
		</nav>
		<nav class="header-smart-menu">
	        
    		
    			
    			<a data-idx="0" q-on="click: openSlider(e, 'innerArchive')" href="javascript:void(0)">所有文章</a>
    			
    			
            
    			
            
    			
    			<a data-idx="1" q-on="click: openSlider(e, 'aboutme')" href="javascript:void(0)">关于我</a>
    			
    			
            
		</nav>
		<nav class="header-nav">
			<div class="social">
				
					<a class="github" target="_blank" href="https://github.com/jakie13" title="github"><i class="icon-github"></i></a>
		        
					<a class="mail" target="_blank" href="mailto:1334919800@qq.com" title="mail"><i class="icon-mail"></i></a>
		        
			</div>
		</nav>
	</header>		
</div>

    </div>
    <div class="mid-col" q-class="show:isShow,hide:isShow|isFalse">
      <nav id="mobile-nav">
  	<div class="overlay">
  		<div class="slider-trigger"><i class="icon-sort"></i></div>
  		<h1 class="header-author js-mobile-header hide">Jakie13</h1>
  	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
				<img src="http://ohsk3zt5q.bkt.clouddn.com/head_image.JPG" class="js-avatar">
			</div>
			<hgroup>
			  <h1 class="header-author">Jakie13</h1>
			</hgroup>
			
			<nav class="header-menu">
				<ul>
				
					<li><a href="/">主页</a></li>
		        
					<li><a href="/tags/随笔/">随笔</a></li>
		        
		        
		        	<li><a href="/archives/">所有文章</a></li>
		        
				</ul>
			</nav>
			<nav class="header-nav">
				<div class="social">
					
						<a class="github" target="_blank" href="https://github.com/jakie13" title="github"><i class="icon-github"></i></a>
			        
						<a class="mail" target="_blank" href="mailto:1334919800@qq.com" title="mail"><i class="icon-mail"></i></a>
			        
				</div>
			</nav>
		</header>				
	</div>
</nav>

      <div id="wrapper" class="body-wrap">
        <div class="menu-l">
          <div class="canvas-wrap">
            <canvas data-colors="#eaeaea" data-sectionHeight="100" data-contentId="js-content" id="myCanvas1" class="anm-canvas"></canvas>
          </div>
          <div id="js-content" class="content-ll">
            <article id="post-sonar学习笔记" class="article article-type-post " itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      sonar学习笔记
    </h1>
  

        <a href="/2016/12/06/sonar学习笔记/" class="archive-article-date">
  	<time datetime="2016-12-06T08:38:50.000Z" itemprop="datePublished"><i class="icon-calendar icon"></i>2016-12-06</time>
</a>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="sonar简介"><a href="#sonar简介" class="headerlink" title="sonar简介"></a>sonar简介</h1><p>sonar是一款强大的代码质量管理软件。支持本地和服务端分析</p>
<h1 id="sonarQube"><a href="#sonarQube" class="headerlink" title="sonarQube"></a>sonarQube</h1><p>sonarQube是sonar的服务端。使用sonarQube可以自己假设sonar的服务端，并通过网站访问管理。  </p>
<h2 id="下载"><a href="#下载" class="headerlink" title="下载"></a>下载</h2><p>官网地址：<a href="http://www.sonarqube.org/" target="_blank" rel="external">http://www.sonarqube.org/</a><br>ps:  </p>
<ol>
<li>以前的版本是sonarQube和sonarRunner，现在已不支持。qube至少要5.X版本，最好使用最新版本  </li>
<li>sonarQube和scanner版本必须匹配，下载时可以看到对应的版本需求  </li>
</ol>
<h2 id="mysql数据库配置"><a href="#mysql数据库配置" class="headerlink" title="mysql数据库配置"></a>mysql数据库配置</h2><p>创建sonar数据库和用户<br>语句：<br><code>CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;</code><br><code>CREATE USER &#39;sonar&#39; IDENTIFIED BY &#39;sonar&#39;;</code><br><code>GRANT ALL ON sonar.* TO &#39;sonar&#39;@&#39;%&#39; IDENTIFIED BY &#39;sonar&#39;;</code><br><code>GRANT ALL ON sonar.* TO &#39;sonar&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;sonar&#39;;</code><br><code>FLUSH PRIVILEGES;</code><br>查看运行结果：<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube001.jpg" alt="qube1"><br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube002.jpg" alt="qube2"><br>ps：mysql至少需要5.6+版本，低版本不支持  </p>
<h2 id="配置sonarQube"><a href="#配置sonarQube" class="headerlink" title="配置sonarQube"></a>配置sonarQube</h2><p>配置文件为qube安装目录下的conf文件下的sonar.properties文件<br>主要配置内容：数据库地址、账号密码和数据库驱动<br><code>sonar.jdbc.username=数据库用户</code><br><code>sonar.jdbc.password=密码</code><br><code>sonar.jdbc.url=jdbc:mysql://localhost:3307/sonar?</code>  <code>useUnicode=true&amp;characterEncoding=utf8&amp;rewriteBatchedStatements=true&amp;useConfigs=maxPerformance</code><br><code>sonar.jdbc.driver:com.mysql.jdbc.Driver</code><br>ps:  </p>
<ol>
<li>数据地址后的四个设置必须带上，这是sonarQube的前置需求  </li>
<li>数据库驱动只需要配置即可，sonarQube已经集成的大部分驱动，除了oracle。使用oracle数据库需要下载驱动到指定目录下  </li>
<li>网上教程需要下载mysql驱动是因为版本低的原因（网上教程基本都是低版本的，只能作为参考）  <h2 id="启动服务"><a href="#启动服务" class="headerlink" title="启动服务"></a>启动服务</h2>启动程序在安装目录的bin文件下，使用自己系统下对应的启动程序即可<br>例：windows64位<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube003.jpg" alt="qube3"><br>运行StartSonar.bat即可<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube004.jpg" alt="qube4"><br>第一次启动时，如果使用的是mysql数据库，会花费很长时间创建表及插入数据。不要在过程中，关闭窗口<br>数据表：<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube005.jpg" alt="qube5"><br>启动后程序可能自动结束<br>原因：  </li>
<li>使用mysql数据库时，数据库版本不对。需要安装5.6以上版本的mysql数据库  </li>
<li>配置文件错误。检查配置项是否正确  <h2 id="web访问"><a href="#web访问" class="headerlink" title="web访问"></a>web访问</h2>打开浏览器输入地址：<a href="http://localhost:9000/（默认,可自行配置）" target="_blank" rel="external">http://localhost:9000/（默认,可自行配置）</a><br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube006.jpg" alt="qube6"><br>出现类似界面说明服务端启用成功（这是使用中文插件后的界面，初始为英文）  <h2 id="安装中文插件"><a href="#安装中文插件" class="headerlink" title="安装中文插件"></a>安装中文插件</h2>两种方法：  </li>
<li>下载插件到本地目录，重启服务。插件放在extensions\plugins\目录下  </li>
<li>在线安装插件<br>登录后（初始用户名和密码均为admin）打开英文界面对应的配置-系统-更新中心，搜索Chinese Pack，安装插件后刷新界面（如果刷新后不是中文界面就重启qube服务在进入）<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube007.jpg" alt="qube7"><br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/qube008.jpg" alt="qube8"><br>接下来可以使用sonarScanner分析代码并上传<h1 id="sonarScanner"><a href="#sonarScanner" class="headerlink" title="sonarScanner"></a>sonarScanner</h1><h2 id="基础配置"><a href="#基础配置" class="headerlink" title="基础配置"></a>基础配置</h2><h3 id="配置scanner"><a href="#配置scanner" class="headerlink" title="配置scanner"></a>配置scanner</h3>配置文件为conf目录下的sonar-scanner.properties<br>配置项：<br><code>sonar.host.url=sonar服务端地址</code><br><code>sonar.sourceEncoding=UTF-8</code><br><code>sonar.login=admin（登录名）</code><br><code>sonar.password=admin（登录密码）</code>  <h3 id="配置系统参数"><a href="#配置系统参数" class="headerlink" title="配置系统参数"></a>配置系统参数</h3>右击计算机-属性-高级系统设置-环境变量<br>新建SONAR_SCANNER_HOME，值为scanner解压目录<br>在path值后加上%SONAR_SCANNER_HOME%\bin;  <h4 id="检查系统参数是否配置成功"><a href="#检查系统参数是否配置成功" class="headerlink" title="检查系统参数是否配置成功"></a>检查系统参数是否配置成功</h4>cmd命令窗口运行sonar-scanner -v命令，出现如下窗口表示配置成功。出错请检查配置及参数设置<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner001.jpg" alt="scanner1">  <h3 id="配置项目"><a href="#配置项目" class="headerlink" title="配置项目"></a>配置项目</h3>在要分析的项目根目录创建sonar-project.properties文件<br>配置项：<br><code>sonar.projectKey=项目名</code><br><code>sonar.projectName=项目名</code><br><code>sonar.projectVersion=版本号</code><br><code>sonar.sources=源文件夹路径（多个用逗号隔开）</code><br><code>sonar.sourceEncoding=UTF-8</code><br><code>binaries=WebRoot/WEB-INF/classes</code>  <h2 id="分析代码"><a href="#分析代码" class="headerlink" title="分析代码"></a>分析代码</h2>打开cmd窗口<br>切换到分析项目的目录<br>使用到的命令：  </li>
<li>d: –切换根目录  </li>
<li>cd 文件夹名 –进入指定目录  </li>
<li>cd .. –返回上级目录<br>图示：<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner002.jpg" alt="scanner2"><br>运行sonar-scanner命令，出现如下信息表示正在分析代码<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner003.jpg" alt="scanner3"><br>最后出现EXECUTION SUCCESS表示分析成功<br>访问网页可以看到分析的项目<br>ps:<br>使用mysql数据库时，最后上传结果比较慢，刚开始首页看不到分析的项目<br>打开配置-项目-后台任务，如下图可以看到正在执行上传任务<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner004.jpg" alt="scanner4"><br>任务执行成功：<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner005.jpg" alt="scanner5">  <h2 id="分析失败"><a href="#分析失败" class="headerlink" title="分析失败"></a>分析失败</h2><h3 id="Unsupported-major-minor-version-52-0"><a href="#Unsupported-major-minor-version-52-0" class="headerlink" title="Unsupported major.minor version 52.0"></a>Unsupported major.minor version 52.0</h3>原因：java版本问题，默认的java版本和sonar不匹配<br>修改方法：  </li>
<li>cmd命令执行java -version查看当前版本信息<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner006.jpg" alt="scanner6">  </li>
<li>修改系统参数的JAVA_HOME和path（最好系统和用户的都修改）,cmd命令执行set path<br>ps:java默认版本为path里的第一个jdk对应的版本<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner007.jpg" alt="scanner7">  </li>
<li>重新打开cmd窗口执行java -version命令查看默认版本<br>ps:必须重新打开cmd窗口才能看到最新的版本</li>
</ol>
<h3 id="Fail-to-insert-data-of-CE-task"><a href="#Fail-to-insert-data-of-CE-task" class="headerlink" title="Fail to insert data of CE task.."></a>Fail to insert data of CE task..</h3><p>图示：<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner009.jpg" alt="scanner9"><br>原因：MySQL数据库的max_allowed_packet值太小了，不能一次插入分析的内容数据<br>修改方法：  </p>
<ol>
<li>mysql运行show VARIABLES like ‘%max_allowed_packet%’;命令查看当前的设置<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner008.jpg" alt="scanner8">  </li>
<li>修改mysql的配置文件<br>在[mysqld]下加上max_allowed_packet = 32M  </li>
<li>重启mysql服务，运行命令查看是否设置成功；成功后再重启sonarQube服务  </li>
</ol>
<h2 id="安装两个mysql"><a href="#安装两个mysql" class="headerlink" title="安装两个mysql"></a>安装两个mysql</h2><p>原因：目前大部分计算机使用的都是MySQL5.5，sonar新版本不支持该版本。同时又不希望直接删掉5.5来安装更高的版本<br>方法：  </p>
<ol>
<li>下载5.7版本的MySQL数据库，解压到与之前版本不同的目录  </li>
<li>新增my.ini文件，自定义配置项<br>端口号和地址都不能和旧的相同<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner015.jpg" alt="scanner15">  </li>
<li>在解压目录下新增对应的data文件夹  </li>
<li>cmd窗口切换到解压目录的bin文件下  </li>
<li>运行mysqld install MySql3307  –defaults-file=”D:\mysql-5.7.16-winx64\my.ini”命令<br>MySql3307为新服务的名称，不能和旧的相同。后面的地址为使用的配置文件地址  </li>
<li>修改注册表<br>6.1 打开regedit程序<br>6.2 HKEY_LOCAL_MACHINE–&gt;SYSTEM–&gt;CurrentControlSet–&gt;Services下找到MySql3307<br>6.3 修改ImagePath<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner010.jpg" alt="scanner10"><br>6.4 重启电脑或打开任务管理器结束explorer.exe,再应用程序-新任务打开explorer.exe  </li>
<li>启动服务<br>7.1 右键计算机-管理-服务和应用程序-服务，找到MySql3307。查看属性，文件路径是否正确<br>7.2 启动服务<br>7.3 启动失败可能原因<br>7.3.1 文件路径不对，注册表修改后必须重启才有效，方法参照步骤6.4<br>7.3.2 数据库配置错误，初始时只要保留基本配置即可<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner011.jpg" alt="scanner11"><h2 id="web分析结果"><a href="#web分析结果" class="headerlink" title="web分析结果"></a>web分析结果</h2><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner012.jpg" alt="scanner12"><br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner013.jpg" alt="scanner13"><br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/scanner014.jpg" alt="scanner14">  <h1 id="sonarLint"><a href="#sonarLint" class="headerlink" title="sonarLint"></a>sonarLint</h1><h2 id="插件安装"><a href="#插件安装" class="headerlink" title="插件安装"></a>插件安装</h2>使用eclipse自带的Marketplace安装<br>ps:安装前最好先卸载掉之前的lint和qube插件<br>方法：help-Installing Details<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint001.jpg" alt="lint1">  <h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2>安装成功后打开SonarQube Servers、SonarLint Issues窗口<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint002.jpg" alt="lint2"><br>点击SonarQube Servers下的Connect to a SonarQube server<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint003.jpg" alt="lint3"><br>输入sonar server的相关信息，确保连接成功<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint004.jpg" alt="lint4"><br>右键-Update all..可以同步更新服务端配置到本地<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint005.jpg" alt="lint5">  <h2 id="分析项目"><a href="#分析项目" class="headerlink" title="分析项目"></a>分析项目</h2>选择项目-&gt;sonar-lint-&gt;Bind to a SonarProject<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint006.jpg" alt="lint6"><br>若之前没有配置SonarProject,则红框内是新增的链接<br>SonarQube Project里可以搜索与服务端匹配的项目，最后点击finish  </li>
</ol>
<p>项目图标变为如下情况表示成功<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint007.jpg" alt="lint7"><br>ps:  </p>
<ol>
<li>每个项目最好匹配同名的服务端项目，避免冲突  </li>
<li>sonarlint console可以查看执行过程，点击console下拉窗口可以看见<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint008.jpg" alt="lint8"><br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint009.jpg" alt="lint9">  <h2 id="分析时报错"><a href="#分析时报错" class="headerlink" title="分析时报错"></a>分析时报错</h2><h3 id="打开文件自动分析代码时，IO错误"><a href="#打开文件自动分析代码时，IO错误" class="headerlink" title="打开文件自动分析代码时，IO错误"></a>打开文件自动分析代码时，IO错误</h3><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint010.jpg" alt="lint10"><br>产生过程：<br>关联服务端project后取消关联，再次关联分析代码时<br>错误原因：<br>再次关联时配置没有同步下来<br>解决方法：<br>servers-update all project bildings<br>ps:<br>update配置时可能报如下错误，更新失败。重启eclipse即可<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint011.jpg" alt="lint11">  <h2 id="查看分析规则详情"><a href="#查看分析规则详情" class="headerlink" title="查看分析规则详情"></a>查看分析规则详情</h2>sonarLint Issues窗口-右键问题-rule description后在SonarLint Rule Description窗口可以看到详情<br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint012.jpg" alt="lint12"><br><img src="http://ohsk3zt5q.bkt.clouddn.com/blog/sonar/lint013.jpg" alt="lint13">  </li>
</ol>

      

      
    </div>
    <div class="article-info article-info-index">
      
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags"></i>
		<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/sonarqube-sonarscanner-sonarlint/">sonarqube sonarscanner sonarlint</a></li></ul>
	</div>

      

      

      
        
<div class="share-btn share-icons tooltip-left">
  <div class="tooltip tooltip-east">
    <span class="tooltip-item">
      <a href="javascript:;" class="share-sns share-outer">
        <i class="icon icon-share"></i>
      </a>
    </span>
    <span class="tooltip-content">
      <div class="share-wrap">
        <div class="share-icons">
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="icon icon-weibo"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="icon icon-weixin"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="icon icon-qq"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="icon icon-douban"></i>
          </a>
          <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a>
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="icon icon-facebook"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="icon icon-twitter"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="icon icon-google"></i>
          </a>
        </div>
      </div>
    </span>
  </div>
</div>

<div class="page-modal wx-share js-wx-box">
    <a class="close js-modal-close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="http://s.jiathis.com/qrcode.php?url=http://yoursite.com/2016/12/06/sonar学习笔记/" alt="微信分享二维码">
    </div>
</div>

<div class="mask js-mask"></div>
      
      <div class="clearfix"></div>
    </div>
  </div>
</article>

  
<nav id="article-nav">
  
    <a href="/2016/12/06/Markdown常见语法/" id="article-nav-newer" class="article-nav-link-wrap">
      <i class="icon-circle-left"></i>
      <div class="article-nav-title">
        
          Markdown常见语法
        
      </div>
    </a>
  
  
    <a href="/2016/12/06/R语言学习笔记（一）-- 介绍和安装/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">R语言学习笔记（一）</div>
      <i class="icon-circle-right"></i>
    </a>
  
</nav>









          </div>
        </div>
      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
    	<div class="footer-left">
    		&copy; 2016 Jakie13
    	</div>
      	<div class="footer-right">
      		<a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
      	</div>
    </div>
  </div>
</footer>
    </div>
    <script>
	var yiliaConfig = {
		mathjax: false,
		isHome: false,
		isPost: true,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: false,
		root: "/",
		innerArchive: true
	}
</script>

<script src="/./main.js?v=4.0.0.js"></script>


    
<div class="tools-col" q-class="show:isShow,hide:isShow|isFalse" q-on="click:stop(e)">
  <div class="tools-wrap">
    
    	<section class="tools-section tools-section-all" q-show="innerArchive">
        <div class="search-wrap">
          <input class="search-ipt" q-model="search" type="text" placeholder="find something…">
          <i class="icon-search icon" q-show="search|isEmptyStr"></i>
          <i class="icon-close icon" q-show="search|isNotEmptyStr" q-on="click:clearChose(e)"></i>
        </div>
        <div class="widget tagcloud search-tag">
          <p class="search-tag-wording">tag:</p>
          <label class="search-switch">
            <input type="checkbox" q-on="click:toggleTag(e)" q-attr="checked:showTags">
          </label>
          <ul class="article-tag-list" q-show="showTags">
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)">R语言</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)">七牛云 图床</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)">eclipse R语言</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)">hexo blog</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)">sonarqube sonarscanner sonarlint</a>
              </li>
             
              <li class="article-tag-list-item">
                <a href="javascript:void(0)">Markdown</a>
              </li>
            
            <div class="clearfix"></div>
          </ul>
        </div>
        <ul class="search-ul">
          <p q-show="jsonFail" style="padding: 20px; font-size: 12px;">
            缺失模块。<br/>1、在博客根目录（注意不是yilia根目录）执行以下命令：<br/> npm i hexo-generator-json-content --save<br/><br/>
            2、在根目录_config.yml里添加配置：
<pre style="font-size: 12px;" q-show="jsonFail">
  jsonContent:
    meta: false
    pages: false
    posts:
      title: true
      date: true
      path: true
      text: true
      raw: false
      content: false
      slug: false
      updated: false
      comments: false
      link: false
      permalink: false
      excerpt: false
      categories: false
      tags: true
</pre>
          </p>
          <li class="search-li" q-repeat="items" q-show="isShow">
            <a q-attr="href:path|urlformat" class="search-title"><i class="icon-quo-left icon"></i><span q-text="title"></span></a>
            <p class="search-time">
              <i class="icon-calendar icon"></i>
              <span q-text="date|dateformat"></span>
            </p>
            <p class="search-tag">
              <i class="icon-price-tags icon"></i>
              <span q-repeat="tags" q-on="click:choseTag(e, name)" q-text="name|tagformat"></span>
            </p>
          </li>
        </ul>
    	</section>
    

    

    
    	<section class="tools-section tools-section-me" q-show="aboutme">
  	  	
  	  		<div class="aboutme-wrap" id="js-aboutme">新人一枚&lt;br&gt;欢迎讨论&lt;br&gt;&lt;br&gt;</div>
  	  	
    	</section>
    
  </div>
  
</div>
    <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>
  </div>
</body>
</html>